<template>
  <jl-base>
    <jl-header>
      <mt-header title="合同明细" :fixed="true">
        <i slot="left">
          <mt-button icon="back" @click="back"></mt-button>
        </i>
      </mt-header>
    </jl-header>

    <jl-content>
      <mt-navbar v-model="selected">
        <mt-tab-item id="base">基本信息</mt-tab-item>
        <mt-tab-item id="goods">商品信息</mt-tab-item>
      </mt-navbar>

      <mt-tab-container v-model="selected">
        <mt-tab-container-item id="base">
          <div class="w12">
            <div class="dld_body mt10">
              <jl-from-input label="登录单" disabled v-model="list.GCDLD01"/>
              <jl-from-input label="使用单位" disabled v-model="list.SYDW"/>
              <jl-from-input label="合同签订日期" disabled v-model="list.HTQDRQ"/>
              <jl-from-input label="联系人" disabled v-model="list.YHXM"/>
              <jl-from-input label="联系电话" disabled v-model="list.YHDH"/>
              <jl-images label="上传附件" v-model="list.HTSCFJ" :icoShow="false"/>
              <jl-images label="现场图片" v-model="list.BCXCTP" :icoShow="false"/>
              <jl-from-textarea placeholder="工程描述。" v-model="list.GCMS"/>
            </div>
          </div>

          <div class="dld_body mt10">
            <jl-from-input label="审批登记" disabled v-model="list.SPDJ"/>
            <div class='jl_form mt10'>
              <div class='jl_form_item bor_bottom'>
                    <span class='w04 '>
                      是否奖励
                    </span>
                <div class="w08 tr">
                  <nut-switch
                    :active.sync="list.SFJL"
                  >
                  </nut-switch>
                </div>
              </div>
            </div>
          </div>
        </mt-tab-container-item>
      </mt-tab-container>

      <mt-tab-container v-model="selected">
        <mt-tab-container-item id="goods">
          <div class="mb10"></div>
          <template v-for="item in list.SPLB">
            {{item.show}}
            <div class="jl_form bgcolor_white mb10" @click="cli(item)">
              <div class="jl_form_item">
                <span class="w12">{{item.GCSPMC}}</span>
                <span class="w12 mt10 font_size_standard font_gray"><i
                  class="fa fa-map-marker mr5"></i>{{item.AZDZ}}</span>
                <span class="w12 mt10 font_size_standard font_red">小计：<font>合同数量：{{item.SQSL}}</font><font class="ml20">合同金额：{{item.SQJE|money}}</font></span>
                <i class="fa fa-angle-right"></i>
              </div>
            </div>
            <mt-popup style="height: 100%;width: 100%"
                      v-model="item.edit_show"
                      modal="false"
                      position="right">
              <my-goods-edit :goods="item" :order-info="list" v-if="item.edit_show" @back="$forceUpdate()"/>
            </mt-popup>
          </template>
        </mt-tab-container-item>
      </mt-tab-container>

    </jl-content>
  </jl-base>
</template>

<script>
  import MyGoodsEdit from './MyContractGoodsEdit'

  export default {
    components: {MyGoodsEdit},
    data() {
      return {
        selected: 'base',
        edit_show: false,
        jlbh: '',
        bdbh: '',
        list: {}
      }
    },
    methods: {
      back() {
        this.$router.back();
      },
      initData() {
        this.http.find('SCM_GCHT', {
          jlbh: this.jlbh,
          bdbh: this.bdbh
        }).then(v => {
          if ($Utils.isNull(v)) return;
          let list = v[0];
          if (!$Utils.isNull(list['SFJL']['key'])) {
            if (list['SFJL']['key'] == 1) {
              list['SFJL'] = false
            } else {
              list['SFJL'] = true
            }
          }
          list['SPDJ'] = list['SPDJ']['value']
          this.list = Object.assign({}, this.list, list)
          this.$previewRefresh()
        })
      },
      cli(item) {
        item.edit_show = true;
        this.$forceUpdate();
      },
    },
    created() {
      if ($Utils.isNull(this.$route.params.item)) return
      this.jlbh = this.$route.params.item['JLBH'];
      this.bdbh = this.$route.params.item['BDBH'];
      this.initData()
    }
  }
</script>

<style scoped>

</style>
